#include "Sale.h"

unsigned int Sale::last_SaleID = 11000;

void Sale::save(string filename, ofstream & out) {
	out << "[TRANS]" << endl;

	out << this->getDate().get_day() << endl;
	out << this->getDate().get_month() << endl;
	out << this->getDate().get_year() << endl;
	out << this->getDate().get_hour() << endl;
	out << this->getDate().get_minute() << endl;

	if (this->getHasEnded() == true) {
		out << this->getClientEnder() << endl; //clientID or owner
		out << "TRUE" << endl;
	} else {
		out << this->getClientEnder() << endl; //NULL
		out << "FALSE" << endl;
	}

	out << "[ITEMS]" << endl;
	out << this->getItem().getID() << endl;
	out << "[/ITEMS]" << endl;

	out << this->getClientStarter() << endl;
	out << "SALE" << endl;
	out << "[/TRANS]" << endl;
}

void Sale::showTransaction() {
	cout << "Sale - ID: " << saleID << endl;

	if (starterID == "NULL") {
		cout << "No seller yet" << endl;
	} else {
		cout << "Starter ID: " << starterID << endl;
	}
	if (enderID == "NULL") {
		cout << "No buyer yet" << endl;
	} else {
		cout << "Ender ID: " << enderID << endl;
	}
	cout << "----------------------------------------------------------------"
			<< endl;
	item.showItem();
	cout << "****************************************************************"
			<< endl;
}

